/*
 * @lc app=leetcode.cn id=1232 lang=typescript
 *
 * [1232] 缀点成线
 */

// @lc code=start
function checkStraightLine(coordinates: number[][]): boolean {
    const isInLine = (a: number[], b: number[]) => [a[0] - b[0], a[1] - b[1]];
    const [headA, headB, ...others] = coordinates;
    const cache = isInLine(headA, headB);
    for (const iterator of others) {
        const cache2 = isInLine(headA, iterator);
        if (cache2[1] * cache[0] !== cache[1] * cache2[0]) {
            return false;
        }
    }
    return true;
}
// @lc code=end
